import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Read{
    StringTokenizer st=new StringTokenizer("");
    BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
    public String next() throws IOException {
        while (!st.hasMoreTokens()){
            st=new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }
    public String nextLine() throws IOException {
        return bf.readLine();
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}
public class Main {
    public static Read in=new Read();
    public static void main1(String[] args) throws IOException {
        String s= in.next();
        int[] hash=new int[26];
        int n=s.length(),max=0,min=Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            hash[s.charAt(i)-'a']++;
            max=Math.max(max,hash[s.charAt(i)-'a']);
            min=Math.min(min,hash[s.charAt(i)-'a']);
        }
        boolean flag=false;
        for (int i = 2; i < (max-min)/2; i++) {
           if((max-min)%i==0) flag=true;
        }
        if(flag){
            System.out.println("No Answer");
        }
        else {
            System.out.println("Lucky Word");
            System.out.println(max-min);
        }
    }
    public int uniquePaths(int m, int n) {
        int[][] dp=new int[m+1][n+1];
        dp[0][1]=1;
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }
        }
        return dp[m][n];
    }
    public boolean hostschedule (ArrayList<ArrayList<Integer>> schedule) {
        // write code here
        boolean ret = true;
        int[][] sche = new int[schedule.size()][2];
        for (int i = 0; i < schedule.size(); i++) {
            sche[i][0] = schedule.get(i).get(0);
            sche[i][1] = schedule.get(i).get(1);
        }
        Arrays.sort(sche, (a, b)-> {
            if (a[0] == b[0]) return a[1] - b[1];
            else return a[0] - b[0];
        });
        for (int i = 1; i < sche.length ; i++) {
            if (sche[i][0] < sche[i - 1][1]) ret = false;
        }
        return ret;
    }

    public static void main2(String[] args) {
        Scanner in=new Scanner(System.in);
        int n= in.nextInt();
        int[] nums=new int[n];
        int sum=0;
        for (int i = 0; i < n; i++) {
            nums[i]= in.nextInt();
            sum+=nums[i];
        }
        Arrays.sort(nums);
        int sum2=0;
        boolean ret=false;
        for (int i = n-1; i >= 0; i--) {
            sum2+=nums[i];
            sum-=nums[i];
            if(sum==sum2) {
                ret=true;
                break;
            }
        }
        System.out.println(ret);
    }

    public static void main3(String[] args) throws IOException {
        char[] s=in.next().toCharArray();
        int maxLen=0,left=0,right=0;
        while (right<s.length){
            if(check(s,left,right)){
                maxLen=Math.max(right-left+1,maxLen);
                right++;
            }
            else {
                left=right;
            }
        }
        if(maxLen>1) System.out.println(maxLen);
        else System.out.println(-1);
    }
    public static boolean check(char[] s,int left,int right){
        while (left<right){
            if(s[left]==s[right]){
                left++;
                right--;
            }
            else return false;
        }
        return true;
    }
    public static void main4(String[] args) throws IOException {
        char[] s = in.next().toCharArray();
        int maxLen = Integer.MAX_VALUE;
        boolean[][] dp = new boolean[s.length][s.length];
        for (int i = s.length-1; i >= 0; i--) {
            dp[i][i]=true;
            for (int j = i; j < s.length; j++) {
                if(s[i]==s[j]){
                    if(j-i<=1||dp[i+1][j-1]) dp[i][j]=true;
                }
                if(dp[i][j]&&j-i+1>1&&j-i+1<maxLen) maxLen=j-i+1;
            }
        }
        if (maxLen != Integer.MAX_VALUE) System.out.println(maxLen);
        else System.out.println(-1);
    }

    public static void main5(String[] args) throws IOException {
        int n= in.nextInt();
        int[] nums=new int[n];
        for (int i = 0; i < n; i++) {
            nums[i]= in.nextInt();
        }
        int[] f=new int[n],g=new int[n];
        int max=0;
        f[0]=nums[0];
        for (int i = 1; i < n; i++) {
           f[i]=g[i-1]+nums[i];
           g[i]=Math.max(g[i-1],f[i-1]);
           max=Math.max(Math.max(f[i],max),g[i]);
        }
        System.out.println(max);
    }

    public static void main6(String[] args) throws IOException {
        int n= in.nextInt(),p= in.nextInt();
        int[] nums=new int[n];
        int max=0;
        for (int i = 0; i < n; i++) {
            nums[i]= in.nextInt();
            max=Math.max(max,nums[i]);
        }
        int maxLen=0,ret=0;
        for (int i = 1; i <= max; i++) {
            ret=0;
            for (int j = 0; j < n; j++) {
                if(Math.abs(nums[j]-i)<=p) ret++;
            }
            maxLen=Math.max(maxLen,ret);
        }
        System.out.println(maxLen);
    }

    public static void main7(String[] args) throws IOException {
        int n= in.nextInt(),p= in.nextInt();
        int[] nums=new int[n];
        for (int i = 0; i < n; i++) {
            nums[i]= in.nextInt();
        }
        Arrays.sort(nums);
        int left=0,right=0;
        int maxLen=0;
        p*=2;
        while (right<n){
            while (nums[right]-nums[left]>p) left++;
            maxLen=Math.max(maxLen,right-left+1);
            right++;
        }
        System.out.println(maxLen);
    }

    public static void main8(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int ret=n;
        for(int i=0;i<m-1;i++){
            ret=ret*(n-1)%109;
        }
        System.out.print(ret);
    }
    public int minmumNumberOfHost (int n, int[][] startEnd) {
        Arrays.sort(startEnd,(a,b)->{
            if(a[0]==b[0]) return a[1]-b[1];
            else return a[0]-b[0];
        });
        PriorityQueue<Integer> queue=new PriorityQueue<>();
        queue.add(startEnd[0][1]);
        for (int i = 1; i < startEnd.length; i++) {
            int start=startEnd[i][0],end=startEnd[i][1];
            if(start>=queue.peek()){
                queue.poll();
                queue.add(end);
            }
            else {
                queue.add(end);
            }
        }
        return queue.size();
    }
    static int N=1010;
    static int[] dx = {0, 0, -1, 1};
    static int[] dy = {1, -1, 0, 0};
    static char[][] arr=new char[N][N];
    static int[][] vis=new int[N][N];
    static int x1, y1, x2, y2, m, n;
    public static void main9(String[] args) {
        Scanner in = new Scanner(System.in);
        m = in.nextInt();
        n = in.nextInt();
        x1 = in.nextInt();
        y1 = in.nextInt();
        x2 = in.nextInt();
        y2 = in.nextInt();
        for (int i = 1; i <= m; i++) {
            String s=in.next();
            for (int j = 1; j <= n; j++) {
                arr[i][j]=s.charAt(j-1);
            }
        }
        System.out.println(dfs());
    }

    private static int dfs() {
        if (arr[x2][y2] == '*') return -1;
        Queue<int[]> queue = new LinkedList<>();
        queue.add(new int[] {x1, y1});
        while (!queue.isEmpty()) {
            int[] t = queue.poll();
            int a = t[0], b = t[1];
            for (int i = 0; i < 4; i++) {
                int x = a + dx[i], y = b + dy[i];
                if (x >= 1 && x <= m && y >= 1 && y <= n && arr[x][y] == '.' &&
                        vis[x][y] == 0) {
                    queue.add(new int[] {x, y});
                    vis[x][y] = vis[a][b] + 1;
                    if (x == x2 && y == y2) return vis[x][y];
                }
            }
        }
        return -1;
    }

    public static void main10(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- > 0) {
            int num = in.nextInt();
            if (num % 2 == 0) System.out.println(num);
            else {
                int k = -1;
                int s = 0;
                while (num > 0) {
                    int n = num % 10;
                    num /= 10;
                    k++;
                    if (n % 2 == 0) {
                        num = num*(int)Math.pow(10,k+1) +  s*10 + n;
                        break;
                    } else {
                        s = s + n * (int)Math.pow(10, k);
                    }
                }
                if (num == 0) System.out.println(-1);
                else System.out.println(num);
            }
        }
    }
    static int S=15;
    static int[] nums=new int[S];
    static int s,ret;
    static boolean[] check=new boolean[S];
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        s= in.nextInt();
        for (int i = 1; i <= s; i++) {
            nums[i]= in.nextInt();
        }
        dfs(1);
        System.out.println(ret);
    }

    private static void dfs(int pos) {
        if(pos==s+1) {
            ret++;
            return;
        }
        for (int i = 1; i <= s; i++) {
            if(check[i]) continue;
            if(check[nums[i]]) return;
            check[i]=true;
            dfs(pos+1);
            check[i]=false;
        }
    }
    public class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
    public TreeNode(int val) {
      this.val = val;
    }
  }
    int ret2 = -1010;
    public int maxPathSum (TreeNode root) {
        if (root == null) return 0;
        dfs(root);
        return ret2;
    }
    public int dfs(TreeNode root) {
        if (root == null) return 0;
        int l = Math.max(0, dfs(root.left));
        int r = Math.max(0, dfs(root.right));
        ret2 = Math.max(ret2, root.val + r + l);
        return Math.max(root.val+l,root.val+r);
    }
}